<template>
  <div style="height:100%;">
    <el-table
        :data="batchTableData"
        style="width:100%"
        height=100%
        v-loading="loading"
        element-loading-text="数据正在加载中..."
        :header-cell-style="{background:'#eef1f6',color:'#606266'}"
    	>

        <el-table-column
          label="批次名称"
          align=center
          width="180">
          <template slot-scope="scope">
            <span style="margin-left: 10px">{{ scope.row.batchName }}</span>
          </template>
        </el-table-column>
    	<el-table-column
    	  label="专家评审开始日期"
    	  align=center
    	 >
    	  <template slot-scope="scope">
    	    <i class="el-icon-time"></i>
    	    <span style="margin-left: 10px">{{ scope.row.phaseExpertStart }}</span>
    	  </template>
    	</el-table-column>
    	<el-table-column
    	  label="专家评审结束日期"
    	  align=center
    	  >
    	  <template slot-scope="scope">
    	    <i class="el-icon-time"></i>
    	    <span style="margin-left: 10px">{{ scope.row.phaseExpertEnd }}</span>
    	  </template>
    	</el-table-column>
    	</el-table-column>
        <el-table-column
          label="批次类别"
    	  align=center
          >
          <template slot-scope="scope">
            <span >{{ scope.row.levelName }}</span>
          </template>
        </el-table-column>
        <el-table-column
    	align=center
    	label="操作">
          <template slot-scope="scope">
            <el-button
              size="mini"
    		  type="success"
              @click="enterBatch(scope.$index, scope.row)">进入</el-button>
          </template>
        </el-table-column>
      </el-table>
    <div class="resource-page">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :page-sizes="[5,10, 15]"
        :page-size="pagesize"
        :pager-count="7"
        layout=" prev, pager, next,sizes, jumper"
        :total="showTable.length"
      >
      </el-pagination>
    </div>
  </div>


</template>

<script>
	export default {
		mounted() {
      this.teacherinfo = this.$store.state.info
      this.getNowDate()
			this.getBatchByExpertGh()
		},
	    data() {
	      return {
          TempBatchInfo:[],
          pagesize: 5,
          currentPage: 1,
          teacherinfo:'',
           //batch表数据
          batchTableData:[],
          //yyyy-mm-dd型日期
          nowDate:'',
          //加载状态
          loading:true
	      }
	    },
	    methods: {
	    enterBatch(index, row) {
        this.$router.push({path:'/expertProjectAudit',query:{batch_id:row.batchId}})
	      },
		  //获得数据Axios
		  getBatchByExpertGh(){
        this.$api.batch.getBatchInfoByExpert().then((res)=>{
        console.log(res)
        this.batchTableData=res.data.data.filter(item=>item.status==2)
        })
        this.loading=false
		  }
		  ,
		  //得到当前日期
		  getNowDate(){
		    var nowDate = new Date();
		    var year = nowDate.getFullYear();
		    var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1): nowDate.getMonth() + 1;
		    var day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate
		     .getDate();
		    var dateStr = year + "-" + month + "-" + day;
		    this.nowDate=dateStr
		    console.log("现在日期："+this.nowDate)
		  },
      handleSizeChange(psize) {
        this.pagesize = psize;
      },
      handleCurrentChange(currentPage) {
        this.currentPage = currentPage;
      },
	    },
      computed: {
        //showTable计算属性通过slice方法计算表格当前应显示的数据
        showTable() {
          return this.batchTableData.slice(
            (this.currentPage - 1) * this.pagesize,
            this.currentPage * this.pagesize
          );
        },
      },
	  }
</script>

<style scoped>

</style>
